﻿<!-- Copyright 2012-2017 Dmitry Kischenko

Licensed under the Apache License, Version 2.0 (the "License"); 
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 
express or implied. 
See the License for the specific language governing permissions and 
limitations under the License. -->
<Window x:Class="xFunc.Views.SettingsView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:res="clr-namespace:xFunc.Resources"
        xmlns:conv="clr-namespace:xFunc.Converters"
        xmlns:views="clr-namespace:xFunc.Views"
        xmlns:fluent="urn:fluent-ribbon"
        xmlns:maths="clr-namespace:xFunc.Maths;assembly=xFunc.Maths"
        xmlns:exps="clr-namespace:xFunc.Maths.Expressions;assembly=xFunc.Maths"
        Title="{x:Static res:Resource.SettingsViewTitle}" Width="520" Height="340"
        WindowStartupLocation="CenterOwner" ShowInTaskbar="False" ResizeMode="NoResize">
    <Window.Resources>
        <conv:InverseBooleanConverter x:Key="inverseBooleanConverter" />
    </Window.Resources>
    <Window.CommandBindings>
        <CommandBinding Command="views:SettingsView.OKCommand" Executed="OKCommand_Execute" CanExecute="OKCommand_CanExecute" />
        <CommandBinding Command="views:SettingsView.ResetCommand" Executed="ResetCommand_Execute" />
    </Window.CommandBindings>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Label Content="{x:Static res:Resource.SettingsLanguageLabel}" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Target="{Binding ElementName=langComboBox}">
            <Label.ToolTip>
                <ToolTip Content="{x:Static res:Resource.SettingsLanguageToolTip}" />
            </Label.ToolTip>
        </Label>
        <ComboBox x:Name="langComboBox" Margin="0,12,10,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Right" Width="140" SelectedValuePath="Tag">
            <ComboBoxItem Content="{x:Static res:Resource.SettingsAutoLang}" Tag="Auto" />
            <ComboBoxItem Content="English" Tag="En" />
            <ComboBoxItem Content="Русский" Tag="Ru" />
            <ComboBoxItem Content="Українська" Tag="Uk" />
        </ComboBox>

        <CheckBox x:Name="positionCheckBox" Content="{x:Static res:Resource.SettingsWindowPos}" Margin="10,41,10,0" VerticalAlignment="Top" IsChecked="True" />
        <CheckBox x:Name="toolBarCheckBox" Content="{x:Static res:Resource.SettingsRightToolBar}" Margin="10,61,10,0" VerticalAlignment="Top" IsChecked="True" />

        <GroupBox Margin="10,81.098,10,0" VerticalAlignment="Top" Height="89.843">
            <GroupBox.Header>
                <CheckBox x:Name="numAndAngleCheckBox" Content="{x:Static res:Resource.SettingsRemember}" IsChecked="True" />
            </GroupBox.Header>
            <GroupBox.Content>
                <Grid IsEnabled="{Binding Path=IsChecked, ElementName=numAndAngleCheckBox, Converter={StaticResource inverseBooleanConverter}}">
                    <Label Content="{x:Static res:Resource.SettingsAngle}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,6.01,0,0" />
                    <ComboBox x:Name="angleComboBox" HorizontalAlignment="Right" VerticalAlignment="Top" Width="140" SelectedIndex="0" Margin="0,8.01,0,0" SelectedValuePath="Tag">
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsDegree}" Tag="{x:Static exps:AngleMeasurement.Degree}" />
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsRadian}" Tag="{x:Static exps:AngleMeasurement.Radian}" />
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsGradian}" Tag="{x:Static exps:AngleMeasurement.Gradian}" />
                    </ComboBox>
                    <Label Content="{x:Static res:Resource.SettingsNumber}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,36.97,0,0" />
                    <ComboBox x:Name="baseComboBox" HorizontalAlignment="Right" VerticalAlignment="Top" Width="140" SelectedIndex="2" Margin="0,38.97,0,0" SelectedValuePath="Tag">
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsBin}" Tag="{x:Static maths:NumeralSystem.Binary}" />
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsOct}" Tag="{x:Static maths:NumeralSystem.Octal}" />
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsDec}" Tag="{x:Static maths:NumeralSystem.Decimal}" />
                        <ComboBoxItem Content="{x:Static res:Resource.SettingsHex}" Tag="{x:Static maths:NumeralSystem.Hexidecimal}" />
                    </ComboBox>
                </Grid>
            </GroupBox.Content>
        </GroupBox>

        <Label Content="{x:Static res:Resource.SettingsMaxNumber}" HorizontalAlignment="Left" Margin="10,171.94,0,0" VerticalAlignment="Top" />
        <TextBox x:Name="maxCountOfExpsTextBox" HorizontalAlignment="Right" Height="23" Margin="0,175.941,10,0" TextWrapping="Wrap" Text="20" VerticalAlignment="Top" Width="140" VerticalContentAlignment="Center" TextAlignment="Right" />

        <Label Content="{x:Static res:Resource.SettingsDefaultChartColor}" HorizontalAlignment="Left" Margin="10,197,0,0" VerticalAlignment="Top" />
        <TextBox x:Name="chartColorTextBox" HorizontalAlignment="Right" Height="23" Margin="0,204,47,0" TextWrapping="Wrap" Text="#FFFF0000" VerticalAlignment="Top" Width="103" VerticalContentAlignment="Center" TextAlignment="Right" />
        <fluent:DropDownButton HorizontalAlignment="Right" VerticalAlignment="Top" SizeDefinition="Small" Margin="0,204,10,0" >
            <fluent:DropDownButton.Icon>
                <Rectangle VerticalAlignment="Bottom" Height="16" Width="16" HorizontalAlignment="Center">
                    <Rectangle.Fill>
                        <SolidColorBrush Color="{Binding Path=Text, ElementName=chartColorTextBox, Mode=TwoWay}" />
                    </Rectangle.Fill>
                </Rectangle>
            </fluent:DropDownButton.Icon>
            <fluent:ColorGallery x:Name="chartColorGallery" IsAutomaticColorButtonVisible="False" IsNoColorButtonVisible="False" SelectedColor="{Binding Path=Text, ElementName=chartColorTextBox, Mode=TwoWay}" />
        </fluent:DropDownButton>

        <CheckBox x:Name="saveUserFuncCheckBox" Content="{x:Static res:Resource.SettingsSaveUF}" Margin="10,228,10,0" VerticalAlignment="Top" IsChecked="True" />
        <CheckBox x:Name="saveDumpCheckBox" Content="{x:Static res:Resource.SettingsSaveDump}" Margin="10,248,10,0" VerticalAlignment="Top" IsChecked="False" />

        <Grid Grid.Row="1" Background="#FFEFEFEF" Height="39">
            <Button Content="{x:Static res:Resource.SettingsReset}" HorizontalAlignment="Left" Margin="10,10,0,8" Padding="8,0,8,0" MinWidth="75" Command="views:SettingsView.ResetCommand" />

            <Button Content="{x:Static res:Resource.SettingsSave}" HorizontalAlignment="Right" Margin="0,10,87,8" Padding="8,0,8,0" MinWidth="75" Command="views:SettingsView.OKCommand" IsDefault="True" />
            <Button Content="{x:Static res:Resource.SettingsCancel}" HorizontalAlignment="Right" Margin="0,10,8,8" Padding="8,0,8,0" MinWidth="75" IsCancel="True" />
        </Grid>
    </Grid>
</Window>
